The Sound Manager provides functions that allow you to determine the version numbers both of the Sound Manager itself and of the MACE compression and expansion routines. Generally, you should avoid trying to determine which features or routines are present by reading a version number. Usually, the Gestalt function (discussed in the previous section) provides a better way to find out if some set of features, such as sound input capability, is available. In some cases, however, you can use these version routines to overcome current limitations of the information returned by Gestalt .
Both of these functions return a value of type NumVersion that contains the same information as the first 4 bytes of a resource of type 'vers' . The first and second bytes contain the major and minor version numbers, respectively; the third and fourth bytes contain the release level and the stage of the release level. For most purposes, the major and minor release version numbers are sufficient to identify the version. (See the chapter "Finder Interface" of Inside Macintosh: Macintosh Toolbox Essentials for a complete discussion of the format of 'vers' resources.)
You can use the SndSoundManagerVersion function to determine which version of the Sound Manager is present. Listing 1-20 shows how to determine if the enhanced Sound Manager is available.
Listing 20 Determining if the enhanced Sound Manager is present
FUNCTION MyHasEnhancedSoundManager: Boolean;
VAR
myVersion: NumVersion;
BEGIN
IF MyTrapAvailable(_SoundDispatch) THEN
BEGIN
myVersion := SndSoundManagerVersion;
MyHasEnhancedSoundManager := myVersion.majorRev >= 2;
END
ELSE
MyHasEnhancedSoundManager := FALSE
END;
The MyHasEnhancedSoundManager function defined in Listing 1-20 relies on the MyTrapAvailable function, which is an application-defined routine provided in Inside Macintosh: Operating System Utilities . If the _SoundDispatch trap is not available, the SndSoundManagerVersion function is not available either, in which case the enhanced Sound Manager is certainly not available.
You can use the MACEVersion function to determine the version number of the available MACE routines (for example, Comp3to1 ).
| Previous | Chapter contents | Chapter top | Section top | Next |